import { Component } from 'solid-js'
import S from './article.module.styl'
import { useGame } from './game'

const Stat: Component = () => {
  const { store, clearStat } = useGame()

  const total = () => store.stat.win + store.stat.lose
  return <div class={S.content}>
    <p>总计 {total()} 局，我方胜利 {store.stat.win} 局，对方胜利 {store.stat.lose} 局。</p>
    {total() && <p>胜率 {(store.stat.win / total() * 100).toFixed(2)}%。</p>}
    <p><button onClick={clearStat}>清除统计数据</button></p>
  </div>
}

export default Stat
